package org.megha.blog.example.part6;

/** A sphere with a volume and surface area */
public class Sphere extends ThreeDObject {

	double radius;

	public Sphere(double radius) {
		this.radius = radius;
	}

	@Override
	public double getSurfaceArea() {
		return (4 * Math.PI * radius * radius);
	}

	@Override
	public double getVolume() {
		// note that doing 4 / 3 * Math.PI * radius * radius * radius
  		// yields a differnt result as
		// 4 / 3 (integer division) equals 1
		return (4 * Math.PI * radius * radius * radius) / 3;
	}

	@Override
	public String toString() {
		return "sphere radius(" + radius + ")";
	}
}
